package com.muyu.product.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import io.swagger.annotations.*;
import com.muyu.common.core.annotation.Excel;
import com.muyu.product.domain.req.CommentInfoQueryReq;
import com.muyu.product.domain.req.CommentInfoSaveReq;
import com.muyu.product.domain.req.CommentInfoEditReq;
import com.muyu.common.core.web.domain.BaseEntity;

/**
 * 商品评论对象 comment_info
 *
 * @author DongZeLiang
 * @date 2024-02-27
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("comment_info")
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "CommentInfo", description = "商品评论")
public class CommentInfo extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /** 主键 */
    @TableId(value = "id",type = IdType.AUTO)
    @ApiModelProperty(name = "主键", value = "主键")
    private Long id;

    /** 商品id */
    @Excel(name = "商品id")
    @ApiModelProperty(name = "商品id", value = "商品id", required = true)
    private Long projectId;

    /** 评论 */
    @Excel(name = "评论")
    @ApiModelProperty(name = "评论", value = "评论")
    private String comment;

    /** 图片 */
    @Excel(name = "图片")
    @ApiModelProperty(name = "图片", value = "图片")
    private String images;

    /** 父类id */
    @Excel(name = "父类id")
    @ApiModelProperty(name = "父类id", value = "父类id")
    private String parentId;

    /**
    * 查询构造器
    */
    public static CommentInfo queryBuild( CommentInfoQueryReq commentInfoQueryReq){
        return CommentInfo.builder()
                .projectId(commentInfoQueryReq.getProjectId())
                .comment(commentInfoQueryReq.getComment())
                .images(commentInfoQueryReq.getImages())
                .parentId(commentInfoQueryReq.getParentId())
                .build();
    }

    /**
    * 添加构造器
    */
    public static CommentInfo saveBuild(CommentInfoSaveReq commentInfoSaveReq){
        return CommentInfo.builder()
                .projectId(commentInfoSaveReq.getProjectId())
                .comment(commentInfoSaveReq.getComment())
                .images(commentInfoSaveReq.getImages())
                .parentId(commentInfoSaveReq.getParentId())
                .build();
    }

    /**
    * 修改构造器
    */
    public static CommentInfo editBuild(Long id, CommentInfoEditReq commentInfoEditReq){
        return CommentInfo.builder()
            .id(id)
                .projectId(commentInfoEditReq.getProjectId())
                .comment(commentInfoEditReq.getComment())
                .images(commentInfoEditReq.getImages())
                .parentId(commentInfoEditReq.getParentId())
                .build();
    }

}
